package com.yanqu.road.server.cmd.activity.stronghold.wild;

import com.yanqu.road.entity.activity.stronghold.StrongholdWildReport;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.pb.activity.StrongholdWarProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.strongholdwar.StrongholdModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

import java.util.List;

@Cmd(code = GameProtocol.S_STRONGHOLD_WAR_WILD_REPORT, desc = "获取野外据点战报")
public class GetStrongholdWildReportCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        List<StrongholdWildReport> wildReportList = player.getModule(StrongholdModule.class).getWildReportList();
        StrongholdWarProto.WildReportRespMsg.Builder resp = StrongholdWarProto.WildReportRespMsg.newBuilder();
        int num = 0;
        for (StrongholdWildReport report : wildReportList) {
            StrongholdWarProto.WildReportTempMsg.Builder msg = StrongholdWarProto.WildReportTempMsg.newBuilder();
            msg.setServerId(report.getEnemyServerId());
            msg.setPlayerData(PlayerBasePb.parsePlayerBaseTempMsg(report.getEnemyUserBaseInfo()));
            msg.setRewardPoints(report.getRewardPoints());
            msg.addAllBox(report.getBoxList());
            msg.setType(report.getType());
            msg.setFightTime(report.getReportTime() / 1000);
            msg.setWin(report.isWin());
            msg.setUserId(report.getEnemyUserId());
            resp.addReport(msg);
            num++;
            if (num >= 50) {
                break;
            }
        }
        player.sendPacket(ClientProtocol.U_STRONGHOLD_WAR_WILD_REPORT, resp);
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
